Class SparseMatrix
- java.lang.Object
-
- edu.claflin.finder.logic.communities.struct.fast_greedy_struct.SparseMatrix
-
public class SparseMatrix extends java.lang.ObjectSparseMatrix is a sparse matrix with row format.
-
-
Field Summary
Fields Modifier and Type Field Description java.util.HashMap<java.lang.Integer,java.util.PriorityQueue<HeapNodeFG>>heapsprivate introwsjava.util.HashMap<java.lang.Integer,BinarySearchTree<TreeNodeInfoFG>>trees
-
Constructor Summary
Constructors Constructor Description SparseMatrix(int rows)empty sparse matrix with allocated number of rows
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int i, int j, double q)Add the given j index, q value pair to the ith tree and heapvoidaddHeap(int i, int j, double q)Add the given j index, q value pair to the ith heap.voidaddTree(int i, int j, double q)Add the given j index, q value pair to the ith tree.voidclearRow(int i)Clear the ith tree and heapjava.lang.Doubleget(int i, int j)get number at index or null if not set.HeapNodeFGgetMax(int i)Get the maximum q value at row ivoidmergeTrees(int j, int i)Merge Trees j and i into j, summing values if the same column occurs.voidrebuildHeap(int j)Rebuild heap j with the tree jprivate voidremoveFromTree(int i, int j)introws()get the rows of the matrixvoidset(int i, int j, double q)Set the q value at the ith tree and heap's j column.voidsetHeap(int i, int j, double q)Set the value q and the ith heap's j column.voidsetTree(int i, int j, double q)Set value q and the ith tree's j column.java.lang.StringtoString()
-
-
-
Field Detail
-
heaps
public java.util.HashMap<java.lang.Integer,java.util.PriorityQueue<HeapNodeFG>> heaps
-
trees
public java.util.HashMap<java.lang.Integer,BinarySearchTree<TreeNodeInfoFG>> trees
-
rows
private int rows
-
-
Method Detail
-
rows
public int rows()
get the rows of the matrix- Returns:
- the number of rows in the matrix
-
add
public void add(int i, int j, double q)Add the given j index, q value pair to the ith tree and heap- Parameters:
i- the row to addj- the j indexq- the q value
-
addTree
public void addTree(int i, int j, double q)Add the given j index, q value pair to the ith tree.- Parameters:
i- the row to addj- the j indexq- the q value
-
addHeap
public void addHeap(int i, int j, double q)Add the given j index, q value pair to the ith heap.- Parameters:
i- the row to addj- the j indexq- the q value
-
get
public java.lang.Double get(int i, int j)get number at index or null if not set.- Parameters:
i- the row to searchj- the colum to search- Returns:
- the q value if it exists or null
-
setTree
public void setTree(int i, int j, double q)Set value q and the ith tree's j column. add it if it's not there.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
setHeap
public void setHeap(int i, int j, double q)Set the value q and the ith heap's j column. add it if it's not there.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
set
public void set(int i, int j, double q)Set the q value at the ith tree and heap's j column.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
removeFromTree
private void removeFromTree(int i, int j)
-
getMax
public HeapNodeFG getMax(int i)
Get the maximum q value at row i- Parameters:
i- the row to search in- Returns:
- the maximum q value
-
clearRow
public void clearRow(int i)
Clear the ith tree and heap- Parameters:
i- the row to clear in
-
mergeTrees
public void mergeTrees(int j, int i)Merge Trees j and i into j, summing values if the same column occurs.- Parameters:
j- the tree to expandi- the tree that offers its Nodes
-
rebuildHeap
public void rebuildHeap(int j)
Rebuild heap j with the tree j- Parameters:
j- the heap to rebuild
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-